<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>日期对象常用方法</title>
</head>
<body>
<script type="text/javascript">
// 获取日期对象： new Date()
var Odate = new Date();
// 获得年月日 、时分秒
var year = Odate.getFullYear();
var month = Odate.getMonth()+1;
month = month<10?'0'+month:month;
var day = Odate.getDate();

var hour = Odate.getHours();
var minute = Odate.getMinutes();
var second = Odate.getSeconds();

// document.write('当前时间：'+year+'-'+month+'-'+day+'&nbsp;&nbsp;'+hour+':'+minute+':'+second);

// 获取星期
var week = Odate.getDay();
// document.write(week);

var milliseconds = Odate.getMilliseconds();
// document.write(milliseconds);

// 获得当前的时间戳 单位是毫秒
var timestamp = Odate.getTime();
// document.write(timestamp);

// 将日期对象转换成本地时间格式
var localtime = Odate.toLocaleString()
// document.write(localtime);


var Odate = new Date();
// 获得年月日 、时分秒
var year = Odate.getFullYear();
var month = Odate.getMonth()+1;
month = month<10?'0'+month:month;
var day = Odate.getDate();
var strTime = '18:00:00';
strTime = year+'-'+month+'-'+day+' '+strTime

var res = Date.parse(strTime)

var date_res = new Date(res)
console.log(strTime, res, date_res)





</script>

</body>
</html>